---
title: Row & Column
---

## Facade API

Complete Facade API type definitions can be found in the [Facade API](https://reference.univer.ai/en-US).

### Row

#### Insert row after given position

[`insertRowAfter(afterPosition)`](https://reference.univer.ai/en-US/classes/FWorksheet#insertrowafter): Inserts a row after the specified row position.

```typescript
const sheet = univerAPI.getActiveWorkbook().getActiveSheet()

// This inserts a row after the first row position
sheet.insertRowAfter(0)
```

#### Insert row before given position

[`insertRowBefore(beforePosition)`](https://reference.univer.ai/en-US/classes/FWorksheet#insertrowbefore): Inserts a row before the specified row position.

```typescript
const sheet = univerAPI.getActiveWorkbook().getActiveSheet()

// This inserts a row before the first row position
sheet.insertRowBefore(0)
```

#### Insert multiple rows at specified location

[`insertRows(rowIndex, numRows)`](https://reference.univer.ai/en-US/classes/FWorksheet#insertrows): Inserts one or more consecutive blank rows in a sheet starting at the specified location.

```typescript
const sheet = univerAPI.getActiveWorkbook().getActiveSheet()

// Shifts all rows down by three
sheet.insertRows(0, 3)
```

#### Insert multiple rows after given position

[`insertRowsAfter(afterPosition, howMany)`](https://reference.univer.ai/en-US/classes/FWorksheet#insertrowsafter): Inserts a specified number of rows after the given row position.

```typescript
const sheet = univerAPI.getActiveWorkbook().getActiveSheet()

// This inserts five rows after the first row
sheet.insertRowsAfter(0, 5)
```

#### Insert multiple rows before given position

[`insertRowsBefore(beforePosition, howMany)`](https://reference.univer.ai/en-US/classes/FWorksheet#insertrowsbefore): Inserts a specified number of rows before the given row position.

```typescript
const sheet = univerAPI.getActiveWorkbook().getActiveSheet()

// This inserts five rows before the first row
sheet.insertRowsBefore(0, 5)
```

#### Delete row at given position

[`deleteRow(rowPosition)`](https://reference.univer.ai/en-US/classes/FWorksheet#deleterow): Deletes the row at the specified row position.

```typescript
const sheet = univerAPI.getActiveWorkbook().getActiveSheet()

// Rows start at "0" - this deletes the first row
sheet.deleteRow(0)
```

#### Delete multiple rows starting at given position

[`deleteRows(rowPosition, howMany)`](https://reference.univer.ai/en-US/classes/FWorksheet#deleterows): Deletes a specified number of rows starting at the given row position.

```typescript
const sheet = univerAPI.getActiveWorkbook().getActiveSheet()

// Rows start at "0" - this deletes the first two rows
sheet.deleteRows(0, 2)
```

#### Move rows to new position

[`moveRows(rowSpec, destinationIndex)`](https://reference.univer.ai/en-US/classes/FWorksheet#moverows): Moves the rows selected by the given range to the position indicated by the `destinationIndex`. The `rowSpec` itself does not have to exactly represent an entire row or group of rows to move—it selects all rows that the range spans.

```typescript
// The code below moves rows 1-2 to destination index 5
// This results in those rows becoming rows 3-4
const sheet = univerAPI.getActiveWorkbook().getActiveSheet()

// Selects row 1 and row 2 to be moved
const rowSpec = sheet.getRange('1:2')
sheet.moveRows(rowSpec, 5)
```

#### Hide rows in given range

[`hideRow(row)`](https://reference.univer.ai/en-US/classes/FWorksheet#hiderow): Hides the rows in the specified range.

```typescript
const sheet = univerAPI.getActiveWorkbook().getActiveSheet()

// This hides the first row
const range = sheet.getRange('1:1')
sheet.hideRow(range)
```

#### Hide multiple consecutive rows

[`hideRows(rowIndex, numRows)`](https://reference.univer.ai/en-US/classes/FWorksheet#hiderows): Hides one or more consecutive rows starting at the given index. Use 0-index for this method.

```typescript
const sheet = univerAPI.getActiveWorkbook().getActiveSheet()

// Hides the first three rows
sheet.hideRows(0, 3)
```

#### Unhide row in given range

[`unhideRow(row)`](https://reference.univer.ai/en-US/classes/FWorksheet#unhiderow): Unhides the row in the specified range.

```typescript
const sheet = univerAPI.getActiveWorkbook().getActiveSheet()

// This unhides the first row if it was previously hidden
const range = sheet.getRange('1:1')
sheet.unhideRow(range)
```

#### Unhide multiple consecutive rows

[`showRows(rowIndex, numRows)`](https://reference.univer.ai/en-US/classes/FWorksheet#showrows): Unhides one or more consecutive rows starting at the given index. Use 0-index for this method.

```typescript
const sheet = univerAPI.getActiveWorkbook().getActiveSheet()

// Unhides the first three rows
sheet.showRows(0, 3)
```

#### Set row height

[`setRowHeight(rowPosition, height)`](https://reference.univer.ai/en-US/classes/FWorksheet#setrowheight): Sets the row height of the given row in pixels. By default, rows grow to fit cell contents. If you want to force rows to a specified height, use `setRowHeightsForced(startRow, numRows, height)`.

```typescript
const sheet = univerAPI.getActiveWorkbook().getActiveSheet()

// Sets the first row to a height of 200 pixels
sheet.setRowHeight(0, 200)
```

#### Set height for multiple rows

[`setRowHeights(startRow, numRows, height)`](https://reference.univer.ai/en-US/classes/FWorksheet#setrowheights): Sets the height of the given rows in pixels. By default, rows grow to fit cell contents. If you want to force rows to a specified height, use `setRowHeightsForced(startRow, numRows, height)`.

```typescript
const sheet = univerAPI.getActiveWorkbook().getActiveSheet()

// Sets the first three rows to a height of 200 pixels
sheet.setRowHeights(0, 3, 200)
```

#### Force set height for multiple rows

[`setRowHeightsForced(startRow, numRows, height)`](https://reference.univer.ai/en-US/classes/FWorksheet#setrowheightsforced): Sets the height of the given rows in pixels. By default, rows grow to fit cell contents. When you use `setRowHeightsForced`, rows are forced to the specified height even if the cell contents are taller than the row height.

```typescript
const sheet = univerAPI.getActiveWorkbook().getActiveSheet()

// Sets the first three rows to a height of 5 pixels
sheet.setRowHeightsForced(0, 3, 5)
```

#### Auto resize rows

[`autoResizeRows(startRow, numRows)`](https://reference.univer.ai/en-US/classes/FWorksheet#autoresizerows): Automatically resizes the height of the given rows to fit their text content.

```typescript
const sheet = univerAPI.getActiveWorkbook().getActiveSheet()

// Set the first 3 rows to a height that fits their text.
sheet.autoResizeRows(0, 3)
```

#### Set row custom properties

[`setRowCustom(custom)`](https://reference.univer.ai/en-US/classes/FWorksheet#setrowcustom): Set custom properties for given rows, store an object `custom` on the row, in which you can put any data that conforms to the JSON format, for custom storage of some additional information.
Updating `custom` data will overwrite the original `custom` data. If you need to keep the original `custom` data when updating data, please get the `custom` data in advance and merge it into new data before updating.

```typescript
const sheet = univerAPI.getActiveWorkbook().getActiveSheet()

// Set custom properties for the first and third rows
sheet.setRowCustom({
  0: { color: 'red' },
  2: { size: 16 },
})
```

### Column

#### Insert column after given position

[`insertColumnAfter(afterPosition)`](https://reference.univer.ai/en-US/classes/FWorksheet#insertcolumnafter): Inserts a column after the given column position.

```typescript
const sheet = univerAPI.getActiveWorkbook().getActiveSheet()

// This inserts a column after the first column position
sheet.insertColumnAfter(0)
```

#### Insert column before given position

[`insertColumnBefore(beforePosition)`](https://reference.univer.ai/en-US/classes/FWorksheet#insertcolumnbefore): Inserts a column before the given column position.

```typescript
const sheet = univerAPI.getActiveWorkbook().getActiveSheet()

// This inserts a column in the first column position
sheet.insertColumnBefore(0)
```

#### Insert multiple columns at specified location

[`insertColumns(columnIndex, numColumns)`](https://reference.univer.ai/en-US/classes/FWorksheet#insertcolumns): Inserts one or more consecutive blank columns in a sheet starting at the specified location.

```typescript
const sheet = univerAPI.getActiveWorkbook().getActiveSheet()

// Shifts all columns by three
sheet.insertColumns(0, 3)
```

#### Insert multiple columns after given position

[`insertColumnsAfter(afterPosition, howMany)`](https://reference.univer.ai/en-US/classes/FWorksheet#insertcolumnsafter): Inserts a given number of columns after the given column position.

```typescript
const sheet = univerAPI.getActiveWorkbook().getActiveSheet()

// Inserts two columns after the first column
sheet.insertColumnsAfter(0, 2)
```

#### Insert multiple columns before given position

[`insertColumnsBefore(beforePosition, howMany)`](https://reference.univer.ai/en-US/classes/FWorksheet#insertcolumnsbefore): Inserts a number of columns before the given column position.

```typescript
const sheet = univerAPI.getActiveWorkbook().getActiveSheet()

// This inserts five columns before the first column
sheet.insertColumnsBefore(0, 5)
```

#### Delete column at given position

[`deleteColumn(columnPosition)`](https://reference.univer.ai/en-US/classes/FWorksheet#deletecolumn): Deletes the column at the given column position.

```typescript
const sheet = univerAPI.getActiveWorkbook().getActiveSheet()

// Columns start at "0" - this deletes the first column
sheet.deleteColumn(0)
```

#### Delete multiple columns starting at given position

[`deleteColumns(columnPosition, howMany)`](https://reference.univer.ai/en-US/classes/FWorksheet#deletecolumns): Deletes a number of columns starting at the given column position.

```typescript
const sheet = univerAPI.getActiveWorkbook().getActiveSheet()

// Columns start at "0" - this deletes the first two columns
sheet.deleteColumns(0, 2)
```

#### Move columns to new position

[`moveColumns(columnSpec, destinationIndex)`](https://reference.univer.ai/en-US/classes/FWorksheet#movecolumns): Moves the columns selected by the given range to the position indicated by the `destinationIndex`. The `columnSpec` itself does not have to exactly represent an entire column or group of columns to move—it selects all columns that the range spans.

```typescript
// The code below moves rows A-B to destination index 5.
// This results in those columns becoming columns C-D.
const sheet = univerAPI.getActiveWorkbook().getActiveSheet()

// Selects column A and column B to be moved.
const columnSpec = sheet.getRange('A:B')
sheet.moveColumns(columnSpec, 5)
```

#### Hide columns in given range

[`hideColumn(column)`](https://reference.univer.ai/en-US/classes/FWorksheet#hidecolumn): Hides the column or columns in the given range.

```typescript
const sheet = univerAPI.getActiveWorkbook().getActiveSheet()

// This hides the first column
const range = sheet.getRange('A:A')
sheet.hideColumn(range)
```

#### Hide multiple consecutive columns

[`hideColumns(columnIndex, numColumns)`](https://reference.univer.ai/en-US/classes/FWorksheet#hidecolumns): Hides one or more consecutive columns starting at the given index. Use 0-index for this method.

```typescript
const sheet = univerAPI.getActiveWorkbook().getActiveSheet()

// Hides the first three columns
sheet.hideColumns(0, 3)
```

#### Unhide column in given range

[`unhideColumn(column)`](https://reference.univer.ai/en-US/classes/FWorksheet#unhidecolumn): Unhides the column in the given range.

```typescript
const sheet = univerAPI.getActiveWorkbook().getActiveSheet()

// This unhides the first column if it was previously hidden
const range = sheet.getRange('A:A')
sheet.unhideColumn(range)
```

#### Unhide multiple consecutive columns

[`showColumns(columnIndex, numColumns)`](https://reference.univer.ai/en-US/classes/FWorksheet#showcolumns): Unhides one or more consecutive columns starting at the given index. Use 0-index for this method.

```typescript
const sheet = univerAPI.getActiveWorkbook().getActiveSheet()

// Unhides the first three columns
sheet.showColumns(0, 3)
```

#### Set column width

[`setColumnWidth(columnPosition, width)`](https://reference.univer.ai/en-US/classes/FWorksheet#setcolumnwidth): Sets the width of the given column in pixels.

```typescript
const sheet = univerAPI.getActiveWorkbook().getActiveSheet()

// Sets the first column to a width of 200 pixels
sheet.setColumnWidth(0, 200)
```

#### Set width for multiple columns

[`setColumnWidths(startColumn, numColumns, width)`](https://reference.univer.ai/en-US/classes/FWorksheet#setcolumnwidths): Sets the width of the given columns in pixels.

```typescript
const sheet = univerAPI.getActiveWorkbook().getActiveSheet()

// Sets the first three columns to a width of 200 pixels
sheet.setColumnWidths(0, 3, 200)
```

#### Auto resize columns

[`autoResizeColumns(startColumn, numColumns)`](https://reference.univer.ai/en-US/classes/FWorksheet#autoresizecolumns): Sets the width of the given columns to automatically fit their text content.

```typescript
const sheet = univerAPI.getActiveWorkbook().getActiveSheet()

// Set the A:C columns to a width that fits their text.
sheet.autoResizeColumns(0, 3)
```

#### Set column custom properties

[`setColumnCustom(custom)`](https://reference.univer.ai/en-US/classes/FWorksheet#setcolumncustom): Set custom properties for given columns, store an object `custom` on the column, in which you can put any data that conforms to the JSON format, for custom storage of some additional information.
Updating `custom` data will overwrite the original `custom` data. If you need to keep the original `custom` data when updating data, please get the `custom` data in advance and merge it into new data before updating.

```typescript
const sheet = univerAPI.getActiveWorkbook().getActiveSheet()

// Set custom properties for the first and third columns
sheet.setColumnCustom({
  0: { color: 'red' },
  2: { size: 16 },
})
```
